Streamlit for Data Science by Tyler Richards
Author:Tyler Richards
Language: eng
Format: epub
Tags: COM060150 - COMPUTERS / Web / User Generated Content, COM021040 - COMPUTERS / Databases / Data Warehousing, COM051460 - COMPUTERS / Programming / Mobile Devices
Publisher: Packt
Published: 2023-09-22T03:51:24+00:00
Picking colors with a color picker
Colors are very difficult to take in as user input in apps. If a user wants red, do they want light red or dark red? Maroon or a pinkish red? Streamlitâs approach to this problem is st.color_picker(), which lets the user pick a color as a part of their user input, and returns that color in a hex string (which is a unique string that defines very specific color shades used by most graphing libraries as input). The following code adds this color picker to our previous app and changes the color of the Seaborn graphs to be based on the color that the user selects:
import pandas as pd import plotly.express as px import streamlit as st st.set_page_config(layout="wide") st.title("SF Trees") st.write( """ This app analyses trees in San Francisco using a dataset kindly provided by SF DPW. The dataset is filtered by the owner of the tree as selected in the sidebar! """ ) trees_df = pd.read_csv("trees.csv") today = pd.to_datetime("today") trees_df["date"] = pd.to_datetime(trees_df["date"]) trees_df["age"] = (today - trees_df["date"]).dt.days unique_caretakers = trees_df["caretaker"].unique() owners = st.sidebar.multiselect("Tree Owner Filter", unique_caretakers) graph_color = st.sidebar.color_picker("Graph Colors") if owners: trees_df = trees_df[trees_df["caretaker"].isin(owners)]
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Android | E-Readers |
Handheld & Mobile Devices | iPad |
iPhone | Programming & App Development |
Tablets |
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(6255)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(5968)
Kotlin in Action by Dmitry Jemerov(4653)
React Native - Building Mobile Apps with JavaScript by Novick Vladimir(2344)
Learning Angular - Second Edition by Christoffer Noring(2172)
Pride and Prejudice by Jane Austen(2103)
Mobile Forensics Cookbook by Igor Mikhaylov(1815)
Computers For Seniors For Dummies by Nancy C. Muir(1773)
Bulletproof Android: Practical Advice for Building Secure Apps (Developer's Library) by Godfrey Nolan(1672)
Building Android UIs with Custom Views by Raimon Ràfols Montané(1624)
Android Development with Kotlin by Marcin Moskala & Igor Wojda(1619)
Building Progressive Web Apps: Bringing the Power of Native to the Browser by Ater Tal(1535)
1936941139 (N) by Bob Rosenthal(1506)
Android App Development by Franceschi Hervé J.;(1499)
Ember.js in Action by Joachim Haagen Skeie(1473)
Hands-On Internet of Things with MQTT by Tim Pulver(1433)
Hands-On Design Patterns with React Native by Mateusz Grzesiukiewicz(1420)
Practical Industrial Internet of Things Security by Sravani Bhattacharjee(1320)
Voice User Interface Projects by Henry Lee(1272)